$(function(){			   	
	$("#mainMenu a span")
	.css( {backgroundPosition: "left 0"} )
	.mouseover(function(){
		jQuery(this).stop().animate({backgroundPosition:"(0 -44px)"}, {duration:300})
	})
	.mouseout(function(){
		jQuery(this).stop().animate({backgroundPosition:"(left 0)"}, {duration:300})
	});
	var value = "";
	$('.text').focus(function() {
		value=$(this).val();
		$(this).attr("value","");
	});
	$('.text').blur(function() {
		if($(this).val()=="") {
			$(this).val(value);
		}
	});

	//prepend span tag to text
  	$(".gradient_txt").prepend("<span></span>");
});

function showSlidingDiv(){
	if($("#slidingDiv_child").css("display") != "none") $("#slidingDiv_child").css("display","none");
	$("#slidingDiv").animate({"width": "toggle"}, { duration: 1000,
													complete: function() {
														$("#slidingDiv_child").fadeIn("fast");
													}
	});		
}
//]]>
//<![CDATA[
function showSlidingDiv1(){
	if($("#slidingDiv_child1").css("display") != "none") $("#slidingDiv_child1").css("display","none");
	$("#slidingDiv1").animate({"width": "toggle"}, { duration: 1000,
													complete: function() {
														$("#slidingDiv_child1").fadeIn("fast");
													}
	});	
}
//]]>

//This is for text gradient

function bind_tabs_click(){
    $("#sendButton").click(function(){
       if ($('#tipenvenForm').valid() == true)
            {
				//alert('fr click');
				_extra_mwc_show_message('tipenvenForm');
			}
       return false;
    });
    $("#newsletterButton").click(function(){
        if ($('#nyhedsbrevForm').valid() == true)
		{
			//alert('newsletter click');
            _extra_mwc_show_message('nyhedsbrevForm');
		}
        return false;
    });
    $("#cancelButton").click(function(){
      //if ($('#newsletter-form').valid() == true)
            //_extra_mwc_show_message('newsletter-form');
       //return false;
	   $("#inputNewsletter").attr("value","");
    });
}
function _extra_mwc_validate(){   

$("#tipenvenForm").validate({
            errorPlacement: function(error, element) {
                //element.hide();
            },
            showErrors:function(errorMap,errorList){},
            invalidHandler: function(form, validator) {
                var invalid = validator.errorMap;
                var count = 0;
                for(key in invalid) {
                 if (count ==0){
                         //
                        if (key =='desc'){
                           alert($("textarea[name='"+key+"']").prev().html().replace(/:/,'')+" skal udfyldes!");
                        }else{
                        
                          // alert($("input[name='"+key+"']").prev().html().replace(/:/,'')+" skal udfyldes!");   
                           alert ("Email skal udfyldes!");
                        }
                        
                 }
                 count++;
                }

            }                                                                                
        });
$("#nyhedsbrevForm").validate({
            errorPlacement: function(error, element) {
                //element.hide();
            },
            showErrors:function(errorMap,errorList){},
            invalidHandler: function(form, validator) {
                var invalid = validator.errorMap;
                var count = 0;
                for(key in invalid) {
                 if (count ==0){
                         //
                        if (key =='desc'){
                           alert($("textarea[name='"+key+"']").prev().html().replace(/:/,'')+" skal udfyldes!");
                        }else{
                        
                          // alert($("input[name='"+key+"']").prev().html().replace(/:/,'')+" skal udfyldes!");   
                           alert ("Email skal udfyldes!");
                        }
                        
                 }
                 count++;
                }

            }                                                                                
        });
}

function _extra_mwc_show_message(idForm){
     var options = {};  
    //alert('extra show msg ' + idForm);
    if (idForm =='tipenvenForm'){ 
        //$('#tell-a-friend-child').hide('slide',options,1500,function(){
                //$('#tell-a-friend-child').html('Loading ...').show('slide',options,1000,function(){
                    mwc_get_variable_and_sent_to_server_json('tipenvenForm'); 
					
                //});    
        //}); 
                       
    }
	if (idForm =='nyhedsbrevForm'){ 
        //$('#tell-a-friend-child').hide('slide',options,1500,function(){
																	 
	
				
                //$('#tell-a-friend-child').html('Loading ...').show('slide',options,1000,function(){
                    mwc_get_variable_and_sent_to_server_json('nyhedsbrevForm'); 
					
                //});    
        //}); 
                       
    }
} 
function mwc_get_variable_and_sent_to_server_json(idForm){
    var data = {};
    var options = {}; 
    var html_message = 'Tak for din henvendelse! <br/>Vi vil kontakte dig hurtigst muligt <br/>Med venlig hilsen ';
    data.fields = $('#'+idForm).serializeArray();
    if (idForm =='tipenvenForm'){data.task = '3';}
	if (idForm =='nyhedsbrevForm'){data.task = '4';}
    //if (idForm =='bestil-form') {data.task = '2';}
	//alert(idForm);
    Drupal.service('mwc.contact',data,function(status, data) {
		//alert(status);								   //alert(status);
           if(status == false) {
                  alert("Fatal error: could not load content");
           }
           else {
               
                    if (data.Task =='Tell-A-Friend'){ 
					
						$('#tipenvenMsg').fadeIn().animate({opacity: '+=0'}, 2000).fadeOut('slow');
						$("#inputTipenven").attr("value","Indtast Email Adresse...");
					   
                       // $('#tell-a-friend-child').hide('pulsate',options,500,function(){                          
                            //$('#tell-a-friend-child').html(html_message).css('opacity',1).show('blind',options,1000);
                        //})
                    }
					if (data.Task =='Register-Newletter'){ 
					
                       $('#newsletterMsg').fadeIn().animate({opacity: '+=0'}, 2000).fadeOut('slow');
					   $("#inputNewsletter").attr("value","Indtast Email Adresse...");
					   
					   //$('#tell-a-friend-child').hide('pulsate',options,500,function(){                          
                            //$('#tell-a-friend-child').html(html_message).css('opacity',1).show('blind',options,1000);
                       // })
                    }
              
           }
    });     
}
//$(function(){
  // bind_tabs_click();   
  // _extra_mwc_validate()  ;  
//});
/*
$(document).ready(function() {
	$('a').each(function(index) {
    
    if($(this).attr("href")=='/test/node/5')
    {
        $(this).attr("href","/test/node/6")
    }
    if($(this).attr("href")=='/test/node/4')
    {
        $(this).attr("href","/test/node/6")
    }

    if($(this).attr("href")=='/test/node/7')
    {
        $(this).attr("href","/test/node/6")
    }
    if($(this).attr("href")=='/test/node/8')
    {
        $(this).attr("href","/test/node/6")
    }
    if($(this).attr("href")=='/test/node/9')
    {
        $(this).attr("href","/test/node/6")
    }
    if($(this).attr("href")=='/test/cart')
    {
        $(this).attr("href","/test/node/6")
    }
    if($(this).attr("href")=='/test/node/85')
    {
        $(this).attr("href","/test/node/6")
    }
    if($(this).attr("href")=='/test/node/87')
    {
        $(this).attr("href","/test/node/6")
    }

    if($(this).attr("href")=='/test/en/node/56'
||$(this).attr("href")=='/test/en/node/54'
||$(this).attr("href")=='/test/en/node/11'
||$(this).attr("href")=='/test/en/node/12'
||$(this).attr("href")=='/test/en/node/57'
||$(this).attr("href")=='/test/en/node/95'
||$(this).attr("href")=='/test/en/cart'
||$(this).attr("href")=='/test/en/node/84'
||$(this).attr("href")=='/test/en/node/86'
||$(this).attr("href")=='12#teknologi'
||$(this).attr("href")=='12#design'
)
    {
        $(this).attr("href","/test/en/node/55")
    }


 });

});

$(document).ready(function() {
	$('a').each(function(index) {
    
	
    if($(this).attr("href")=='http://mywebcreations.dk/test')
    {
        $(this).attr("href","#")
    }
	 if($(this).attr("href")=='/test/.')
    {
        $(this).attr("href","#")
    }

    if($(this).attr("href")=='8#teknologi')
    {
        $(this).attr("href","#")
    }
    if($(this).attr("href")=='8#design')
    {
        $(this).attr("href","#")
    }
     if($(this).attr("href")=='http://mywebcreations.dk/test')
    {
        $(this).attr("href","#")
    }

	if($(this).attr("href")=='/test/node/5')
    {
        $(this).attr("href","#")
    }
    if($(this).attr("href")=='/test/node/4')
    {
        $(this).attr("href","#")
    }

    if($(this).attr("href")=='/test/node/7')
    {
        $(this).attr("href","#")
    }
    if($(this).attr("href")=='/test/node/8')
    {
        $(this).attr("href","#")
    }
    if($(this).attr("href")=='/test/node/9')
    {
        $(this).attr("href","#")
    }
    if($(this).attr("href")=='/test/cart')
    {
        $(this).attr("href","#")
    }
    if($(this).attr("href")=='85')
    {
        $(this).attr("href","#")
    }
    if($(this).attr("href")=='/test/node/87')
    {
        $(this).attr("href","#")
    }

    if($(this).attr("href")=='/test/en/node/56'
||$(this).attr("href")=='/test/en/node/54'
||$(this).attr("href")=='/test/en/node/11'
||$(this).attr("href")=='/test/en/node/12'
||$(this).attr("href")=='/test/en/node/57'
||$(this).attr("href")=='/test/en/node/95'
||$(this).attr("href")=='/test/en/cart'
||$(this).attr("href")=='84'
||$(this).attr("href")=='/test/en/node/86'
||$(this).attr("href")=='12#teknologi'
||$(this).attr("href")=='12#design'
||$(this).attr("href")=='/test/en/.'


)
    {
        $(this).attr("href","#")
    }


 });

});
*/

function showsteps1(){
$("#phase1").animate({"height": "toggle"}, { duration: 1000 });
}

function showsteps12(){
$("#phase1").hide('slow',function(){$("#phase2").show(1000)});
}

function showsteps2(){
$("#phase2").animate({"height": "toggle"}, { duration: 1000 });
}

function showsteps23(){
$("#phase2").hide('slow',function(){$("#phase3").show(1000)});
}

function showsteps3(){
$("#phase3").animate({"height": "toggle"}, { duration: 1000 });
}

function showsteps34(){
$("#phase3").hide('slow',function(){$("#phase4").show(1000)});
}

function showsteps4(){
$("#phase4").animate({"height": "toggle"}, { duration: 1000 });
}

function showsteps45(){
$("#phase4").hide('slow',function(){$("#phase5").show(1000)});
}

function showsteps5(){
$("#phase5").animate({"height": "toggle"}, { duration: 1000 });
}